# -*- coding: utf-8 -*-
"""
@Time ： 2023/4/4 20:51
@Auth ： Mr. William 1052949192
@Company ：特斯汀学院 @testingedu.com.cn
@Function ：图文验证码破解
"""
import time

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

from class10.verify import Verify

option = Options()
# 不自动关闭浏览器的配置
option.add_experimental_option("detach", True)
driver = webdriver.Chrome(options=option)
driver.maximize_window()
driver.implicitly_wait(3)

# 登录
driver.get('http://testingedu.com.cn:8000/Home/user/login.html')
# 定位元素-操作元素
driver.find_element('xpath', '//*[@id="username"]').send_keys('13800138006')
driver.find_element('xpath', '//*[@id="password"]').send_keys('1234561')

# 截图
ele = driver.find_element('xpath','//*[@id="verify_code_img"]')
ele.screenshot('./verify.png')

verify = Verify('wuqingfqng', '6e8ebd2e301f3d5331e1e230ff3f3ca5', '904357')
pic_ver = verify.PostPic(1902,'./verify.png')

driver.find_element('xpath', '//*[@id="verify_code"]').send_keys(pic_ver)
time.sleep(6)
driver.find_element('xpath', '//*[@id="loginform"]/div/div[6]/a').click()


